<?php
include('connectDB.php');
$tang=$_GET['tang'];
//$daynha=$_GET['daynha'];
$get_room="select * from phong where matang =".$tang;
$query=mysql_query($get_room);
$list_room=array();
while($rows=mysql_fetch_array($query)){
	$temp=array();
	$temp['maphong']=$rows['maphong'];
	$temp['sosinhvien']=$rows['sosinhvien'];
	$temp['loaiphong']=$rows['loaiphong'];
	array_push($list_room,$temp);
}

echo"<table border='1' style='margin-top:30px;'>";
           echo"  <tbody>";
            echo" <tr>";          
			 $count=0;
             foreach($list_room as $value){
				 $count++;
				 if($count==0){
					 echo "<tr>";					
				 }	
				 if($value['sosinhvien']==8){				             
         		   echo "<td height='50' width='50' style='background:red;' align='center'>
				   <div class='room' id='room'>".$value['maphong']."<br>".$value['sosinhvien']."/8</div></td>";
				 }else{
				echo "<td height='50' width='50' style='background:green;' align='center'>
				<div class='room' id='room'>".$value['maphong']."<br>".$value['sosinhvien']."/8</div></td>"; 
				 }
			 if($count==5){
				  $count=0;
			 echo "</tr>";
				 }
			 }
            echo " </tr>";
           echo " </tbody>";
           echo " </table>";
?>